import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:part_time_job_pro/common/cache/app_box.dart';
import 'package:part_time_job_pro/common/store/config.dart';
import 'package:part_time_job_pro/common/langs/local.dart';

import 'state.dart';

class LangSettingLogic extends GetxController {
  final LangSettingState state = LangSettingState();

  @override
  void onInit() {
    super.onInit();
    //设置默认值
    state.currentLanguageIndex.value = AppBox.shared.language;
  }

  //修改语言
  void changeLanguage(int index) {
    Local.changeLanguage(index);
    update();
    //返回上一页
    Future.delayed(Duration(milliseconds: 500), () {
      Get.back(result: index);
    });
  }
}
